package com.sky.controller.admin;

import com.sky.dto.OrdersPageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.admin.OrderService;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController("adminOrderController")
@RequestMapping("/admin/order")
@Api(tags = "服务端订单接口")
@Slf4j
public class OrderController {
    @Resource
    OrderService orderService;

    @GetMapping("/conditionSearch")
    @ApiOperation("订单搜索")
    public Result<PageResult> search(OrdersPageQueryDTO dto){
          return orderService.conditionSearch(dto);
    }
    @GetMapping("/statistics")
    @ApiOperation("各个状态的订单数量统计")
    public Result<OrderStatisticsVO> statistics(){
        OrderStatisticsVO statistics = orderService.statistics();
        log.warn("订单数量的统计数据:{}",statistics);
        return Result.success(statistics);
    }
    @GetMapping("/details/{id}")
    @ApiOperation("商家查看详情订单接口")
    public Result<OrderVO> details(@PathVariable Long id){
        log.warn("商家查询的订单详情的Id:{}",id);
        OrderVO orderVO = orderService.adminOrderDetails(id);
        return Result.success(orderVO);
    }

}
